package BinaryTree;

import com.sun.org.apache.bcel.internal.generic.NameSignatureInstruction;

import java.util.Stack;

/*
https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef?tpId=60&&tqId=29483&rp=1&ru=/activity/oj&qru=/ta/tsing-kaoyan/question-ranking
KY11 二叉树遍历
* import java.util.Scanner;

class TreeNode {
    public char val;
    public TreeNode left;
    public TreeNode right;

    public TreeNode (char val) {
        this.val = val;
    }


}

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
         Main main=new Main();
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            TreeNode tree = main.createTree(str); //创造一个树
            main.MediumOrder(tree);
        }
    }


    //进行中序遍历然后输出
    private void MediumOrder(TreeNode root){
        if(root==null){
            return;
        }
         MediumOrder(root.left);
        System.out.print(root.val+" ");
        MediumOrder(root.right);
    }
    //创造一个先序遍历的树
    int i=0;
     private  TreeNode createTree(String str) {
        char ch = str.charAt(i);
        TreeNode node=null;
        if(ch!='#'){
         node=new TreeNode(ch);
        i++;
        node.left=createTree(str);
        node.right=createTree(str);
        }else{
            i++;
            return null;
        }
        return node;
    }
}
* */
public class Test {
    public static void main(String[] args) {
        BinaryTree binaryTree=new BinaryTree();
//
//        binaryTree.levelOrder2(binaryTree.createTree());
        System.out.println(binaryTree.isCompleteTree(binaryTree.createTree()));

    }
    public static void main3(String[] args) {
        BinaryTree tree=new BinaryTree();
        BinaryTree.TreeNode tree1=tree.createTree();
        tree.levelOrder(tree1);

    }
    public static void main2(String[] args) {
        BinaryTree tree=new BinaryTree();
        BinaryTree.TreeNode tree1=tree.createTree();
        int size=tree.getKLevelNodeCount(tree.createTree(),3);

        System.out.println(size);
        int size2=tree.getHeight(tree1);
        System.out.println(size2);
        System.out.println(tree.find(tree1,'F').val);

    }
    public static void main1(String[] args) {
        BinaryTree tree=new BinaryTree();
        int si=tree.getLeafNodeCount2(tree.createTree());
        System.out.println(si);

    }
}
